package t10086.Repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;
import t10086.Model.Entity.Order;

import java.util.List;


public interface OrderRepository extends JpaRepository<Order, String> {

    @Query("SELECT o1 from Order o1 where o1.status = :status")
    List<Order> findOrdersByStatus(@Param("status") int status);

    @Modifying
    @Transactional
    @Query("UPDATE Order o1 SET o1.status = :status WHERE o1.orderNumber = :orderNumber")
    int updateStatusByOrderNumber(@Param("orderNumber") String orderNumber, @Param("status") int status);
}
